package com.itboye.mengwu.data.presenter;

import java.util.List;
import java.util.Observer;

import com.itboye.core.interfaces.ICompleteListener;
import com.itboye.core.object.BasePresenter;
import com.itboye.core.object.ResultEntity;
import com.itboye.mengwu.app.ui.main.MainPresenter;
import com.itboye.mengwu.data.interfaces.IDingdanXiangQing;
import com.itboye.mengwu.data.model.DingdanXiangQingBean;
import com.itboye.mengwu.data.repository.DingdanRepository;

public class DingdanPresenter extends BasePresenter implements
		IDingdanXiangQing<DingdanXiangQingBean> {
	public static final String ShopDingdan_success = MainPresenter.class
			.getName() + "_ShopDingdan_success";
	public static final String ShopDingdanFailEvent = MainPresenter.class
			.getName() + "_ShopDingdan_fail";

	public DingdanPresenter(Observer observer) {
		super(observer);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void add(DingdanXiangQingBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void delete(DingdanXiangQingBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void update(DingdanXiangQingBean model) {
		// TODO Auto-generated method stub

	}

	@Override
	public void getInfo(DingdanXiangQingBean model) {
		// TODO Auto-generated method stub
		IDingdanXiangQing<DingdanXiangQingBean> carDelete = new DingdanRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ShopDingdan_success);
						DingdanPresenter.this.setChanged();
						DingdanPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(ShopDingdanFailEvent);
						DingdanPresenter.this.setChanged();
						DingdanPresenter.this.notifyObservers(result);
					}
				});

		carDelete.getInfo(model);

	}

	@Override
	public List<DingdanXiangQingBean> queryYouHuiQuan(DingdanXiangQingBean model) {
		// TODO Auto-generated method stub
		IDingdanXiangQing<DingdanXiangQingBean> carDelete = new DingdanRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ShopDingdan_success);
						DingdanPresenter.this.setChanged();
						DingdanPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(ShopDingdanFailEvent);
						DingdanPresenter.this.setChanged();
						DingdanPresenter.this.notifyObservers(result);
					}
				});
		carDelete.getInfo(model);// (uid,);
		return null;
	}

	@Override
	public void getQueRen(String uid, String order_code) {
		// TODO Auto-generated method stub

		IDingdanXiangQing<DingdanXiangQingBean> carDelete = new DingdanRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ShopDingdan_success);
						DingdanPresenter.this.setChanged();
						DingdanPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(ShopDingdanFailEvent);
						DingdanPresenter.this.setChanged();
						DingdanPresenter.this.notifyObservers(result);
					}
				});
		carDelete.getQueRen(uid, order_code);// (uid,);
	}

	@Override
	public void getYunFei(String uid, String address_id, String cart_ids) {
		// TODO Auto-generated method stub

		IDingdanXiangQing<DingdanXiangQingBean> carDelete = new DingdanRepository(
				new ICompleteListener() {

					@Override
					public void success(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Success);
						result.setEventType(ShopDingdan_success);
						DingdanPresenter.this.setChanged();
						DingdanPresenter.this.notifyObservers(result);
					}

					@Override
					public void failure(ResultEntity result) {
						// TODO Auto-generated method stub
						result.setEventTag(Tag_Error);
						result.setEventType(ShopDingdanFailEvent);
						DingdanPresenter.this.setChanged();
						DingdanPresenter.this.notifyObservers(result);
					}
				});
		carDelete.getYunFei(uid, address_id, cart_ids);

	}

}
